const { execSql } = require("../utils/db")

class chat{
    static async getRobotMsg(msg){
        let res;
        try {
            res = await execSql(`select * from lv_kf_robot where getmsg='`+`${msg}'`)
        } catch (error) {
            res = null
        }
        
        return res
    }

    static async addChat(obj){
        let res
        try {
            res = await execSql(`INSERT INTO lv_chat (uid, msg, addtime, kfid, kfmsg) VALUES ('${obj.uid}', '${obj.msg}', '${obj.addtime}', ${obj.kfid}, '${obj.kfmsg}')`)
        } catch (error) {
            res =null
        }
        
        return res
    }

    static async getChat(uid){
        let res = await execSql(`select * from lv_chat where uid=${uid}`)
        return res
    }

    static async getUserList(){
        let res = await execSql(`select * from lv_user`)
        return res
    }
}
module.exports=chat